package com.yanqu.road.server.logic.activity.relation.condition.chefduel;

import com.yanqu.road.entity.activity.ActivityConditionInfo;
import com.yanqu.road.entity.activity.chefduel.process2.ChefDuel2Dish;
import com.yanqu.road.entity.enums.eGamePlayerEventType;
import com.yanqu.road.server.gameplayer.GamePlayer;
import com.yanqu.road.server.gameplayer.module.task.TaskModule;
import com.yanqu.road.server.logic.activity.relation.RelationActivityData;
import com.yanqu.road.server.logic.activity.relation.condition.BaseRelationActivityRankCondition;

import java.math.BigInteger;

public class ChefDuel2MakeDishUnlockCondition extends BaseRelationActivityRankCondition {

    public ChefDuel2MakeDishUnlockCondition(GamePlayer player, RelationActivityData activityData, ActivityConditionInfo conditionInfo) {
        super(player, activityData, conditionInfo);
    }

    @Override
    public void addTrigger(GamePlayer player) {
        player.getModule(TaskModule.class).getGameEvent().addListener(eGamePlayerEventType.ChefDuel2MakeDishUnLock.getValue(), handle);
    }

    @Override
    public void removeTrigger(GamePlayer player) {
        player.getModule(TaskModule.class).getGameEvent().removeListener(eGamePlayerEventType.ChefDuel2MakeDishUnLock.getValue(), handle);
    }

    @Override
    public boolean isCompleted(GamePlayer player) {
        return false;
    }

    @Override
    protected void player_BoardLevelHandle(Object object) {
        //解锁首次烹饪出某道菜
        ChefDuel2Dish cookBoy2Dish = (ChefDuel2Dish) object;
        int dishId = getConditionInfo().getParamList().get(2).intValue();
        if(cookBoy2Dish.getDishId() == dishId){
            setValue(BigInteger.valueOf(1));
        }
    }
}
